#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int judge(char a, char b) {
  if (a == b) return 1;
  if ((a == 'R' && b == 'S') || (a == 'S' && b == 'P') || (a == 'P' && b == 'R')) return 2;
  return 0;
}

int calculate_score(const vector<int>& nums) {
  int max_score = 0;
  for (int i = 0; i < 3; i++) {
    max_score = max(max_score, nums[i] * 2 + nums[(i + 2) % 3]);
  }
  return max_score;
}


int main() {
  int r, n;
  cin >> r;
  string mine;
  cin >> mine;
  cin >> n;
  vector<string> players(n);
  vector<int> nums(3);
  for (auto &player : players) cin >> player;
  int ans1 = 0, ans2 = 0;
  for (int i = 0; i < r; i++) {
    for (auto& player : players) {
      ans1 += judge(mine[i], player[i]);
      if (player[i] == 'S') nums[0]++;
      else if (player[i] == 'P') nums[1]++;
      else nums[2]++;
    }
    ans2 += calculate_score(nums);
    for (int i = 0; i < 3; i++) {
      nums[i] = 0;
    }
  }
  cout << ans1 << endl;
  cout << ans2 << endl;
  return 0;
}